import request from '@/api/index'
import {getRequest, postRequest} from '../baseRequest'

// 查看问卷
export const viewFormResultRequest = (formKey) => getRequest(`/user/form/data/view/${formKey}`)
// 保存问卷结果数据
export const createFormResultRequest = (data) => postRequest('/user/form/data/create', data)
// 保存公开问卷结果数据
export const publicCreateFormResultRequest = (data) => postRequest('/user/form/data/public/create', data)
// 查询数据列表
// export const listFormDataTableRequest = (data) => postRequest('/user/form/data/query', data)
export const listFormDataTableRequest = (data) => {
  return request({
    url: '/user/form/data/query',
    method: 'post',
    data: data,
    timeout:3600000,
  })
}
// 查询数据详情
export const getFormDataDetailsRequest = (dataId) => getRequest(`/user/form/data/details/${dataId}`)
// 删除数据
export const deleteFormDataRequest = (data, key) => postRequest(`/user/form/data/delete/${key}`, data)
// 修改数据
export const updateFormDataRequest = (data) => postRequest('/user/form/data/update', data)
// 导出附件
export const downloadFormDataFileRequest = (data) => postRequest('/user/form/data/download/file', data,300000)
// 导出数据
export const exportDataRequest = (data) => {
  return request({
    url: '/user/form/data/exportExcel',
    method: 'post',
    params:{'formKey':data.formKey},
    data: data,
    timeout:3600000,
  })
}
export const realTimeExport = (data) => {
  return request({
    url: '/user/form/data/realTimeExport',
    method: 'post',
    params:{'formKey':data.formKey},
    data: data,
    timeout:3600000,
  })
}
export function batchExportData(data) {
  return request({
      url: `/user/form/batchExportData`,
      method: 'post',
      timeout: 3600000,
      responseType: 'blob',
      data
  })
}
export function batchExportDataPath(data) {
  return request({
      url: `/user/form/batchExportDataPath`,
      method: 'post',
      timeout: 3600000,
      data
  })
}
// 下载导入模板
export const downloadImportTemplateRequest = (params) => {
  return request({
    url: '/user/form/data/import/template',
    method: 'get',
    params: params,
    responseType: 'blob'
  })
}
// 保存评论数据
export const saveReplyRequest = (data) => postRequest('/user/form/data/reply', data)
// 查询回复列表
export const listReplyRequest = (params) => getRequest('/user/form/data/reply/list', params)

export const updatePhone = (params) => getRequest('/user/form/data/update/formDataPhone', params)




